
import {isFunction} from "underscore";
import {isDevContext} from "./context.js";

/**
 * Sends an event to google analytics.
 * https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#events
 *
 * @param {string} category the event category (max 150 bytes)
 * @param {string} action the event action (max 500 bytes)
 * @param {string?} label the event label (max 500 bytes)
 * @param {number?} value the event value (must be non-negative)
 */
export function gaEvent(category, action, label, value) {
    // console.log("** send", "event", ...arguments);
    if (isFunction(window.ga) && !isDevContext()) {
        window.ga("send", "event", ...arguments);
    }
}
